<template>
  <section class="wrapper">
    <myHeader :obj="myObj" @events="events"></myHeader>
    <main>
      <div class="content_0312">
        <div class="items_0312" v-for="(item,index) in items" @click="orselect(index)">
          <i class="sectedIcon_0312" :class="active == index?'activeIcon_0312':''"></i><p class="texts_0312">{{item}}</p>
        </div>
        <div class="hint_0312"><i class="hintIcon_0312"></i>本次取消提示</div>
      </div>
      <myButton @sendDate="cancel">取消约见</myButton>
    </main>
  </section>
</template>
<script>
import myHeader from './base/myHeader';
import myButton from './base/myButton';
import hgjSkip from '../assets/js/hgjSkip';
import API from '../assets/js/asktoses';
import { fetch } from '../assets/api';
import {Toast } from 'mint-ui';
export default {
  props:['obj'],
  data () {
    return {
      myObj: {
        type: 3,
        text: '取消理由'
      },
      items:[
        "不需要",
        "没有钱",
        "弄错了",
        "不是我需要的",
        "选错了",
      ],
      active:0,
      Reasons:"",
      loginData:null,
    }
  },
  created () {
    hgjSkip.skip().then(res =>{
      this.loginData = res;
    })
  },
  methods: {
    events(i){
      if(i == 2) {
        history.back();
      }
    },
    orselect(index){
      this.active = index;
      this.Reasons = this.items[this.active]
    },
    //取消订单
    async cancel(){
      this.Reasons = this.Reasons == ""?this.items[this.active]:this.Reasons
      if (this.$route.query.exper){
        await fetch(API.getMeetOrderexpert,{
          ...this.loginData[1],
          AppointmentOrderNo:this.$route.query.AppointmentOrderNo,
          CancellationReasons:this.Reasons,
        });
      } else {
        await fetch(API.getCancelMeetOrderuser,{
          ...this.loginData[1],
          AppointmentOrderNo:this.$route.query.AppointmentOrderNo,
          CancellationReasons:this.Reasons,
        });
      }
      Toast("取消成功");
      window.history.go(-2)
    },
  },
  components: {
    myHeader,
    myButton
  }
}

</script>
<style lang="less">
.wrapper {
  width: 3.75rem;
  height: 100%;
  main {
    width: 3.75rem;
    height: 100%;
    padding-top: .54rem;
    position: absolute;
    top: 0;
    left: 0;
    overflow-y: auto;
    box-sizing: border-box;
    .content_0312 {
      background: white;
      padding-top: 0.15rem;
      .hint_0312 {
        height: .22rem;
        padding: .13rem;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: .16rem;
        color: #39393D;
        margin-bottom: .52rem;
        .hintIcon_0312 {
          width: .16rem;
          height: .16rem;
          display: block;
          background: url("../assets/img/addressList/search-none.png") center center;
          background-size: cover;
          margin-right: .05rem;
          background-repeat: no-repeat;
        }
      }
      .items_0312 {
        padding-left: .15rem;
        width: 100%;
        height: .35rem;
        display: flex;
        align-items: center;
        margin-bottom: .15rem;
        box-sizing: border-box;
        .sectedIcon_0312 {
          display: block;
          width: .22rem;
          height: .22rem;
          background: #E1E1E1;
          margin-right: .15rem;
          border-radius: 50%;
          border: .01rem solid #C9C9C9;
        }
        .activeIcon_0312 {
           width: .23rem;
          height: .23rem;
          background: url("../assets/img/expert/icon_designate01@3x.png") center center;
          background-size: cover;
          background-repeat: no-repeat;
          border: none;
        }
        .texts_0312 {
          font-size: .16rem;
          color: #39393D;
          display: box;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 1;
          overflow: hidden;
          width: 3rem;
        }

      }
    }
  }
  
}


</style>
